package com.baizhi.controller;

import com.baizhi.Invitation;
import com.baizhi.service.InvitationService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class InvitationController {
    @Autowired
    private InvitationService is;
    @GetMapping("Invitations")
    public Map<String,Object> selectBypage(Integer page,Integer limit){
        PageInfo<Invitation> pageInfo = is.page(page, limit);
        return new HashMap(){{
            put("code",0);
            put("count",pageInfo.getTotal());
            put("data",pageInfo.getList());
            put("msg","");
        }};
    }
    @GetMapping("Invitationss")
    public Map<String,Object> selectWhere(String where){
        System.out.println(where);
        List<Invitation> invitations = is.selectWhere(where);
        return new HashMap(){{
            put("code",0);
            put("count",invitations.size());
            put("data",invitations);
            put("msg","");
        }};
    }
    @DeleteMapping
    public void delete(){}
}
